package logic

import (
	"context"
	"good_srv/goodclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartDelLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCartDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartDelLogic {
	return &CartDelLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CartDelLogic) CartDel(req *types.CartDelRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	auth, err := l.svcCtx.GoodSrv.CartDel(l.ctx, &goodclient.CartDelRequest{
		UserId:  req.UserId,
		GoodsId: req.GoodsId,
	})
	if err != nil {
		return &types.Response{
			Mes:  err.Error(),
			Code: 400,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Mes:  "删除车删除成功",
		Code: 200,
		Data: auth,
	}, nil
}
